export const getQuery = (txt) => {
    let query = location.search,
        queryObj = {}, queryArr;
    queryArr = query.split('&');
    queryArr.map(item => {
        let key = item.split('=')[0],
            value = item.split('=')[1];
        queryObj[key] = value;
    })
    if (txt) {
        if (txt in queryObj)
            return queryObj[txt]
        else
            return '';
    } else {
        return queryObj;
    }
};
export const setQuery = (obj) => {
    let queryString = '';
    try {
        if (typeof obj == 'object') {
            for (let i in obj) {
                if (typeof obj[i] == 'number' ||typeof obj[i] == 'string') {
                    queryString += i + '=' + obj[i] + '&';
                } else if (obj[i] instanceof Array) {
                    for (let j = 0; j < obj[i].length; j++) {
                        queryString += i + '=' + obj[i][j] + '&';
                    }
                }
            }
        }
    } catch (e) {
        console.log(e)
    }
    return queryString;
}
export const deepCopy = (obj) => {
    try{
        return JSON.parse(JSON.stringify(obj))
    }catch(e){
        return null
    }
}
